

$(document).ready(function(){
//所有单选多选按钮应用iCheck样式

  /*
	$('input').iCheck({

    checkboxClass: 'icheckbox_square-green',
    radioClass: 'iradio_square-green'
  });
  */
    //初始化菜单事件
    $(".menu ul li").menu();
  
    $('.dropdown-toggle').dropdown();
  
    // tooltip demo
    $('.tooltip-demo').tooltip({
      selector: "a[data-toggle=tooltip]"
    })
    
    // popover demo
    $("a[data-toggle=popover]")
      .popover()
      .click(function(e) {
        e.preventDefault()
     })

});



/*
封装好的提醒方法，用来替代alert，参数为：标题，内容，类型：info,error,success,自动隐藏的时间
提醒位置增加如下层
<div id="message" class="alert alert-block hide fade in">
				<button type="button" class="close" data-dismiss="alert">&times;</button>
			   <h5 id="message-title">Warning</h5>
			   <span id="message-text"></span>
</div>
*/
function alert_message(title,text,type,time){
        $("#message-title").html(title);
        $("#message-text").html(text);
        $("#message").addClass("alert-"+type);
        $("#message").show();
        window.setTimeout(function() { $("#message").hide() },time);
        
}

//头部表格
function topCommTable() {
	topTableString = "<table width=\"100%\" border=\"1\" cellspacing=\"0\">";

	return topTableString;
}
function endCommTable() {
	topTableString = "</table>";
	return topTableString;
}



//jQuery.cookie 封装
/*调用示例如下
$(document).ready(function() {
	$('#write_cokies').click(function(){
		$.cookie('name', 'test',{expires: 7});				  
	});
	$('#read_ookies').click(function(){
		var test = $.cookie('name');
		alert (test);
	});
	$('#delete_cookies').click(function(){
		$.cookie('name', null);							  
	});
});
*/
jQuery.cookie = function(name, value, options) {
	if (typeof value != 'undefined') {
		options = options || {};
		if (value === null) {
			value = '';
			options = $.extend({}, options);
			options.expires = -1;
		}
		var expires = '';
		if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
			var date;
			if (typeof options.expires == 'number') {
				date = new Date();
				date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
			} else {
				date = options.expires;
			}
			expires = '; expires=' + date.toUTCString();
		}
		var path = options.path ? '; path=' + (options.path) : '';
		var domain = options.domain ? '; domain=' + (options.domain) : '';
		var secure = options.secure ? '; secure' : '';
		document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
		} else {
			var cookieValue = null;
			if (document.cookie && document.cookie != '') {
			var cookies = document.cookie.split(';');
			for (var i = 0; i < cookies.length; i++) {
				var cookie = jQuery.trim(cookies[i]);
				if (cookie.substring(0, name.length + 1) == (name + '=')) {
					cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
					break;
				}
			}
		}
		return cookieValue;
	}
};
Date.prototype.Format = function(fmt) 
{  
	var o = { 
	 "M+" : this.getMonth()+1,                 //月份 
	 "d+" : this.getDate(),                    //日 
	 "h+" : this.getHours(),                   //小时 
	 "m+" : this.getMinutes(),                 //分 
	 "s+" : this.getSeconds(),                 //秒 
	 "q+" : Math.floor((this.getMonth()+3)/3), //季度 
	 "S"  : this.getMilliseconds()             //毫秒 
	}; 
	if(/(y+)/.test(fmt)) 
	 fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length)); 
	for(var k in o) 
	 if(new RegExp("("+ k +")").test(fmt)) 
	fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length))); 
	return fmt; 
};